/**
 * 将数组转换为对象的 key属性
 *  主要用于 store 中
 *
 */
export const translateArrToObj = arr => {
  let obj = {};
  arr.forEach(item => {
    obj[item] = '';
  });
  return obj;
};

export const generateGettersFromArray = (arr, target) => {
  let obj = {};
  arr.forEach(item => {
    obj[`g_${item}`] = state => {
      return state[item];
    };
  });
  return obj;
};

export const generateMutationsFromArray = (arr, target) => {
  let obj = {};
  arr.forEach(item => {
    obj[`s_${item}`] = (state, payload) => {
      state[item] = payload || '';
    };
  });
  return obj;
};
